/*
 * Records package
 */
package edu.gatech.oad.records;
import edu.gatech.oad.persistence.PersistentObject;
import edu.gatech.oad.schedule.Appointment;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
 * Represents an invoice for a certain medical treatment
 * @author Nathan Hurley
 * @version 1.0 3/6/11
 *
 */
public class Invoice extends PersistentObject{
	
	/**
	 * serialization variable
	 */
	private static final long serialVersionUID = 1L;
	
	/**
	 * The current treatment record
	 */
	private TreatmentRecord treatRecord;
	
	/**
	 * If bill has been paid
	 */
	private boolean isPaid;
	
	/**
	 * If the bill has been sent
	 */
	private boolean isSent;
	
	/**
	 * Total cost of the Invoice
	 */
	private double cost;
	
	/**
	 * All of the treatments billed
	 */
	private List<Cost> treatmentsBilled;
	
	/**
	 * Constructs an Invoice object so bill can be 
	 * sent and status of payment can be checked
	 * @param treatRecord
	 */
	public Invoice(TreatmentRecord treatRecord){
		this.treatRecord = treatRecord;
		isPaid = false;
		isSent = false;
		treatmentsBilled = new ArrayList<Cost>();
	}
	
	/**
	 * @param c adds to the billed list
	 */
	public void addTreatment(Cost c){
		treatmentsBilled.add(c);
	}
	
	/**
	 * @param key removes from the treatments billed list
	 */
	public void removeTreatment(Cost key){
		treatmentsBilled.remove(key);
	}
	
	/**
	 * @return ArrayList of billed treatments
	 */
	public List<Cost> getTreatmentsBilled(){
		return treatmentsBilled;
	}
	
	/**
	 * @param treatmentsBilled the new treatments in the Invoice
	 */
	public void setTreatmentsBilled(List<Cost> treatmentsBilled){
		this.treatmentsBilled = treatmentsBilled;
	}
	
	/**
	 * @param isPaid  the new status of whether the bill is paid
	 */
	public void setIsPaid(boolean isPaid){
		this.isPaid = isPaid;
	}
	
	/**
	 * @return  the status of the current invoices payment
	 */
	public boolean equalIsPaid(){
		return isPaid;
	}
	
	/**
	 * @param isSent  change status of invoice being sent
	 */
	public void setIsSent(boolean isSent){
		this.isSent = isSent;
	}
	
	/**
	 * @return  current status regarding if the invoice has been sent
	 */
	public boolean equalIsSent(){
		return isSent;
	}
	
	/**
	 * Gets the total cost for the invoice
	 * 
	 * @return  cost of the invoice
	 */
	public double getCost(){
		return cost;
	}
	
	/**
	 * @param cost new total cost
	 */
	public void setCost(double cost){
		this.cost = cost;
	}
	
	/**
	 * @return the date of the appointment that is being billed
	 */
	public Date getDate(){
		return treatRecord.getDate();
	}
	
	/**
	 * @param treatRecord the new TreatmentRecord for the Invoice
	 */ 
	public void setTreatmentRecord(TreatmentRecord treatRecord){
		this.treatRecord = treatRecord;
	}
	
	/**
	 * @return treatment record associated with the invoice
	 */
	public TreatmentRecord getTreatmentRecord(){
		return treatRecord;
	}
	
	/**
	 * @return Appointment associated with the Invoice
	 */
	public Appointment getAppointment(){
		return treatRecord.getAppointment();
	}
	
	/**
	 * Implementation of toString method
	 * @return Displays date, status of sent
	 * and paid, and the total cost
	 */
	public String toString(){
		return "Date of Invoice: " + getDate() + " Status of Invoice sent: " 
		+ equalIsSent() + " Status of billing: " + equalIsPaid() + 
		" Total cost: " + getCost();
	}
	
}
